﻿using System;
using System.Diagnostics;

namespace MortgageCalculator.Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            //DemoCalculateTable();
            CalculateMaxInterestRate();
        }

        static void DemoCalculateTable()
        {
            var input = new MortgageCalculatorInput
            {
                DurationOfLoan = 360,
                InterestRate = .03m,
                LoanAmount = 200000,
                LoanStartDate = new DateTime(2015, 1, 1),
                PurchasePrice = 300000,
                PropertyTax = 375,
                MaxBalanceAtMiddleDuration = 140000,
                MaxInterestPaidWarning = 180000,
            };

            Console.WriteLine("Input:");
            Console.WriteLine(input);

            var calc = new MortgageCalculator();

            Stopwatch sw = new Stopwatch();
            sw.Start();
            var output = calc.Calculate(input);
            sw.Stop();
            Console.WriteLine("Elapsed Milliseconds: {0}", sw.ElapsedMilliseconds);
            Console.WriteLine();
            Console.WriteLine("Output:");
            Console.WriteLine(output);
        }

        static void CalculateMaxInterestRate()
        {
            var input = new MaxInterestRateCalculatorInput
            {
                DurationOfLoan = 360,
                LoanAmount = 200000,
                LoanStartDate = new DateTime(2015, 1, 1),
                //MaxInterestPaid = 186512
                MaxInterestPaid = 103555
            };

            Console.WriteLine("Input:");
            Console.WriteLine(input);

            var calc = new MortgageCalculator();

            Stopwatch sw = new Stopwatch();
            sw.Start();
            var output = calc.CalculateInterestRateByPaidInterest(input, .005m, .20m);
            sw.Stop();
            Console.WriteLine("Elapsed Milliseconds: {0}", sw.ElapsedMilliseconds);
            Console.WriteLine();
            Console.WriteLine("Output:");
            Console.WriteLine(output);
        }
    }
}
